//
//  CancelDingDanView.m
//  Experss
//
//  Created by wmwMAC on 17/8/10.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "CancelDingDanView.h"

@implementation CancelDingDanView
-(void)setCenterStr:(NSString *)centerStr{
    _centerStr = centerStr;
    [self createUI];
}
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
    
    CGFloat view_height = 150;
    CGFloat view_weidth = kScreenWidth-80;
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(40, kScreenHeight/2-view_height/2, view_weidth, view_height)];
    backView.backgroundColor = [UIColor whiteColor];
    
    backView.layer.cornerRadius = 5;
    backView.clipsToBounds = YES;
    [self addSubview:backView];
    
    UILabel *titleLable = [BasePublicCreatUI createLabelFrame:CGRectMake(0, 10, view_weidth, 40) title:_titleStr textColor:[UIColor blackColor] textAlignment:NSTextAlignmentCenter font:[UIFont systemFontOfSize:18]];
    [backView addSubview:titleLable];
    
    UILabel *centerLable = [BasePublicCreatUI createLabelFrame:CGRectMake(0, CGRectGetMaxY(titleLable.frame), view_weidth, 40) title:_centerStr textColor:[UIColor blackColor] textAlignment:NSTextAlignmentCenter font:[UIFont systemFontOfSize:16]];
    [backView addSubview:centerLable];
    
    UIButton *cancelBtn = [BasePublicCreatUI createBtnFrame:CGRectMake(0, view_height - 50, view_weidth/2, 50) title:@"取消" bgImage:nil selectBgImage:nil image:nil target:self action:@selector(cancelAction:)];
    cancelBtn.backgroundColor = BaseColor;
    cancelBtn.tag = 1001;
    [backView addSubview:cancelBtn];
    
    UIButton *confirmBtn = [BasePublicCreatUI createBtnFrame:CGRectMake(view_weidth/2, view_height - 50, view_weidth/2, 50) title:@"确定" bgImage:@"bg1" selectBgImage:nil image:nil target:self action:@selector(cancelAction:)];
    
    confirmBtn.tag = 1002;
    [confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];;
    [backView addSubview:confirmBtn];
    
}
-(void)cancelAction:(UIButton *)sender{
 
    if (self.reloadBlock)
    {
        self.reloadBlock(sender);//调用回调函数
    }
    
    [self removeFromSuperview];
}

@end
